package com.zhongwang.mms.module.purchase.dao;

import com.zhongwang.mms.gen.entity.*;
import com.zhongwang.mms.module.purchase.model.POrderDetailAndPInventoryModel;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public interface PurPOrderDetailDao {
    long countByExample(POrderDetailExample example);

    int deleteByExample(POrderDetailExample example);

    int deleteByPrimaryKey(Integer odaId);

    int insert(POrderDetail record);

    int insertList(@Param("list") List<POrderDetail> insertList);

    int insertPOrderDetail(POrderDetail record);

    int insertSelective(POrderDetail record);

    List<POrderDetail> selectByExample(POrderDetailExample example);

    POrderDetail selectByPrimaryKey(Integer odaId);

    int updateByExampleSelective(@Param("record") POrderDetail record, @Param("example") POrderDetailExample example);

    int updateByExample(@Param("record") POrderDetail record, @Param("example") POrderDetailExample example);

    int updateByPrimaryKeySelective(POrderDetail record);

    int updateByPrimaryKey(POrderDetail record);
    /**
     *@FunctionName: selectByWhere
     *@Description: 根据条件查询从表列表
     *@Author: 徐一贺
     *@CreateDate: 2020/4/7 14:12
     *@Phone: 18241927380
     *@Param: pOrderDetailObj 条件
     *@Return: List<POrderDetail>从表列表
     *@Version: 1.0.0
     */
    List<POrderDetail> selectByWhere(POrderDetail pOrderDetailObj);
    /**
     *@FunctionName: findOrderDetailListByOdrId
     *@Description: 根据单据主键获取明细
     *@Author: 徐一贺
     *@CreateDate: 2020/4/9 8:54
     *@Phone: 18241927380
     *@Param: odrId 单据主键
     *@Return:  List<POrderDetail>明细列表
     *@Version: 1.0.0
     */
    List<POrderDetail> findOrderDetailListByOdrId(Integer odrId);

    List<POrderDetailAndPInventoryModel> findPOrderDetailAndPInventoryModelListByOdrId(String odaIds);
    List<POrderDetailAndPInventoryModel> findPOrderDetailAndPInventoryModelListByOdrIdOut(String odaIds);

    Integer getPInventoryCountByRowNo(Integer odaId);

    POrderDetail findOrderDetailByOdaId(Integer odaId);

    POrderDetailAndPInventoryModel findPOrderDetailAndPInventoryModelListByOdaId(String odaIds);

    Integer getPInventoryCountByOutItyId(Integer odaId);

    /**
     * 根据调拨单号获取调拨单实体
     * @param odrRepId
     * @return
     */
    AllocationOrder getAllocationOrderByOdrCode(String odrRepId);

    /**
     * 根据主键修改出库状态
     * 如果是3改成2
     * 如果是2改成1
     * @param allocationOrder
     */
    void updateAllocationOrderOdrOutStatusByOdrId(AllocationOrder allocationOrder);

    /**
     * 根据主键更新品牌
     * @param pOrderDetail
     * @return
     */
    int updatePOrderDetailOdaBrandByPrimaryKey(POrderDetail pOrderDetail);

}